home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / AIncludes / AppleEvents.a < prev    next >
Encoding:
Text File  |  1993-09-17  |  24.1 KB  |  584 lines  |  [TEXT/MPS ]

  1. ;    File:        AppleEvents.a
  2. ;
  3. ;    Copyright:    © 1983-1993 by Apple Computer, Inc.
  4. ;                All rights reserved.
  5. ;
  6. ;    Version:    System 7.1 for ETO #11
  7. ;    Created:    Tuesday, March 30, 1993 18:00
  8. ;
  9. ;___________________________________________________________________________
  10.  
  11.  IF &TYPE('__IncludingAppleEvents__') = 'UNDEFINED' THEN
  12. __IncludingAppleEvents__   SET 1
  13.  
  14.  IF &TYPE('__IncludingTraps__') = 'UNDEFINED' THEN
  15.  INCLUDE 'Traps.a'
  16.  ENDIF
  17.  
  18.  
  19. typeLongInteger          EQU          'long'
  20. typeShortInteger         EQU          'shor'
  21. typeLongFloat            EQU          'doub'
  22. typeShortFloat           EQU          'sing'
  23. typeExtended             EQU          'exte'
  24. typeComp                 EQU          'comp'
  25. typeMagnitude            EQU          'magn'
  26. typeAEList               EQU          'list'
  27. typeAERecord             EQU          'reco'
  28. typeTrue                 EQU          'true'
  29. typeFalse                EQU          'fals'
  30. typeAlias                EQU          'alis'
  31. typeEnumerated           EQU          'enum'
  32. typeType                 EQU          'type'
  33. typeAppParameters        EQU          'appa'
  34. typeProperty             EQU          'prop'
  35. typeFSS                  EQU          'fss '
  36. typeKeyword              EQU          'keyw'
  37. typeSectionH             EQU          'sect'
  38. typeWildCard             EQU          '****'
  39.  
  40. typeApplSignature        EQU          'sign'
  41. typeSessionID            EQU          'ssid'
  42. typeTargetID             EQU          'targ'
  43. typeProcessSerialNumber  EQU          'psn '
  44. typeNull                 EQU          'null'         ;the type of null/nonexistent data
  45.  
  46. kCoreEventClass          EQU          'aevt'
  47.  
  48. kAEOpenApplication       EQU          'oapp'
  49. kAEOpenDocuments         EQU          'odoc'
  50. kAEPrintDocuments        EQU          'pdoc'
  51. kAEQuitApplication       EQU          'quit'
  52.  
  53. kAECreatorType           EQU          'crea'
  54. kAEQuitAll               EQU          'quia'
  55. kAEShutDown              EQU          'shut'
  56. kAERestart               EQU          'rest'
  57. kAEApplicationDied       EQU          'obit'
  58. keyProcessSerialNumber   EQU          'psn '
  59.  
  60. keyErrorNumber           EQU          'errn'
  61. keyErrorString           EQU          'errs'
  62.  
  63. kAEAnswer                EQU          'ansr'
  64.  
  65. keyDirectObject          EQU          '----'
  66.  
  67.  
  68. ; keyword used in install special handler 
  69. keyPreDispatch           EQU          'phac'         ; PreHandler Accessor Call 
  70. keySelectProc            EQU          'selh'         ; More selector Call 
  71.  
  72. ; keywords used in attributes 
  73. keyTransactionIDAttr     EQU          'tran'
  74. keyReturnIDAttr          EQU          'rtid'
  75. keyEventClassAttr        EQU          'evcl'
  76. keyEventIDAttr           EQU          'evid'
  77. keyAddressAttr           EQU          'addr'
  78. keyOptionalKeywordAttr   EQU          'optk'
  79. keyTimeoutAttr           EQU          'timo'
  80. keyInteractLevelAttr     EQU          'inte'         ;this attribute is read only will be set in AESend
  81. keyEventSourceAttr       EQU          'esrc'         ; this attribute is read only 
  82. keyMissedKeywordAttr     EQU          'miss'         ; this attribute is read only 
  83.  
  84. ; constants for use in AESendMode 
  85. kAENoReply               EQU          $00000001      ; Sender doesn't want a reply to event 
  86. kAEQueueReply            EQU          $00000002      ; Sender wants a reply but won't wait 
  87. kAEWaitReply             EQU          $00000003      ; Sender wants a reply and will be waiting 
  88.  
  89. kAENeverInteract         EQU          $00000010      ; Server should not interact with user 
  90. kAECanInteract           EQU          $00000020      ; Server may try to interact with user 
  91. kAEAlwaysInteract        EQU          $00000030      ; Server should always interact with user where appropriate 
  92.  
  93. kAECanSwitchLayer        EQU          $00000040      ; Interaction may switch layer 
  94.  
  95. kAEDontReconnect         EQU          $00000080      ; don't reconnect if there is a sessClosedErr from PPCToolbox 
  96.  
  97. kAEWantReceipt           EQU          $00000200      ; Send wants a receipt of message 
  98.  
  99. ; constants to be used in AESendPriority 
  100. kAENormalPriority        EQU          $00000000      ; Post message at the end of event queue 
  101. kAEHighPriority          EQU          $00000001      ; Post message at the front of the event queue 
  102.  
  103. ; special constants in generating events 
  104. kAnyTransactionID        EQU          0              ; no transaction is in use 
  105. kAutoGenerateReturnID    EQU          -1             ; AECreateAppleEvent will generate a session-unique ID 
  106.  
  107. ; constant for use AESend 
  108. kAEDefaultTimeout        EQU          -1             ; timeout value determined by AEM 
  109. kNoTimeOut               EQU          -2             ; wait until reply comes back, however long it takes 
  110.  
  111. ; dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch
  112. ;table, or one of these two constants 
  113. kAENoDispatch            EQU          0
  114. kAEUseStandardDispatch   EQU          -1
  115.  
  116. ; Error messages in response to reading and writing event contents 
  117. errAECoercionFail        EQU          -1700
  118. errAEDescNotFound        EQU          -1701
  119. errAECorruptData         EQU          -1702
  120. errAEWrongDataType       EQU          -1703
  121. errAENotAEDesc           EQU          -1704
  122. errAEBadListItem         EQU          -1705          ; Specified list item does not exist 
  123. errAENewerVersion        EQU          -1706          ; Need newer version of AppleEvent Manager 
  124. errAENotAppleEvent       EQU          -1707          ; The event is not in AppleEvent format 
  125.  
  126. ; Error messages in response to sending/receiving a message 
  127. errAEEventNotHandled     EQU          -1708          ; The AppleEvent was not handled by any handler 
  128. errAEReplyNotValid       EQU          -1709          ; AEResetTimer was passed an invalid reply parameter 
  129. errAEUnknownSendMode     EQU          -1710          ; Mode wasn't NoReply, WaitReply, or QueueReply;     or Interaction level is unknown 
  130. errAEWaitCanceled        EQU          -1711          ; In AESend, User cancelled out of wait loop for  reply or receipt 
  131. errAETimeout             EQU          -1712          ; AppleEvent timed out 
  132.  
  133. errAENoUserInteraction   EQU          -1713          ; no user interaction allowed 
  134. errAENotASpecialFunction EQU          -1714          ; there is no special function with this keyword 
  135. errAEParamMissed         EQU          -1715          ; a required parameter was not accessed 
  136.  
  137. errAEUnknownAddressType  EQU          -1716          ; The target address type is not known 
  138. errAEHandlerNotFound     EQU          -1717          ; No handler in the dispatch tables fits the parameters to
  139.                          ;                                              AEGetEventHandler or AEGetCoercionHandler
  140.  
  141. errAEReplyNotArrived     EQU          -1718          ; the contents of the reply you are accessing have not arrived yet 
  142. errAEIllegalIndex        EQU          -1719          ; Index is out of range in a put operation 
  143.  
  144. ; tagged data, the standard AppleEvent data type 
  145. AEDesc                   RECORD       0
  146. descriptorType           DS.L         1              ; DescType
  147. dataHandle               DS.L         1              ; Handle
  148. size                     EQU          *
  149.                          ENDR
  150.  
  151.  
  152. ;type of param to AEGetInteractionAllowed and AESetInteractionAllowed
  153. kAEInteractWithSelf      EQU          0
  154. kAEInteractWithLocal     EQU          1
  155. kAEInteractWithAll       EQU          2
  156.  
  157. ;Return param to AEGetTheCurrentEvent, and kAEEventSource attribute
  158. kAEUnknownSource         EQU          0
  159. kAEDirectCall            EQU          1
  160. kAESameProcess           EQU          2
  161. kAELocalProcess          EQU          3
  162. kAERemoteProcess         EQU          4
  163.  
  164.  
  165. ; types for AppleEvent Array support 
  166.  
  167. ; Basic data type of attibutes & parameters
  168. AEKeyDesc                RECORD       0
  169. descKey                  DS.L         1              ; AEKeyword
  170. descContent              DS           AEDesc
  171. size                     EQU          *
  172.                          ENDR
  173.  
  174.  
  175. kAEDataArray             EQU          0
  176. kAEPackedArray           EQU          1
  177. kAEHandleArray           EQU          2
  178. kAEDescArray             EQU          3
  179. kAEKeyDescArray          EQU          4
  180.  
  181.  
  182. ; Array routines support these different types of elements
  183. AEArrayData              RECORD       0
  184.                          ORG           AEArrayData
  185. AEDataArray              DS.W         1              ; Array of short
  186.                          ORG           AEArrayData
  187. AEPackedArray            DS.B         1              ; Array of char
  188.                          ORG           AEArrayData
  189. AEHandleArray            DS.L         1              ; Array of Handle
  190.                          ORG           AEArrayData
  191. AEDescArray              DS.B         AEDesc.size*1
  192.                          ORG           AEArrayData
  193. AEKeyDescArray           DS.B         AEKeyDesc.size*1
  194.                          ORG
  195. size                     EQU          *
  196.                          ENDR
  197.  
  198.  
  199.  
  200. ;  *********************************************************************
  201. ;The following calls apply to any AEDesc. Every result descriptor is created for you,
  202. ;so you will be responsible for memory management of the descriptors so created.
  203. ;Purgeable descriptor data is not supported: the AEM does not call LoadResource.  
  204.                          MACRO
  205.                          _AECreateDesc
  206.                          MOVE.W           #$0825,D0
  207.                          _Pack8                      ; A816
  208.                          ENDM
  209.  
  210.                          MACRO
  211.                          _AECoercePtr
  212.                          MOVE.W           #$0A02,D0
  213.                          _Pack8                      ; A816
  214.                          ENDM
  215.  
  216.                          MACRO
  217.                          _AECoerceDesc
  218.                          MOVE.W           #$0603,D0
  219.                          _Pack8                      ; A816
  220.                          ENDM
  221.  
  222.                          MACRO
  223.                          _AEDisposeDesc
  224.                          MOVE.W           #$0204,D0
  225.                          _Pack8                      ; A816
  226.                          ENDM
  227.  
  228.                          MACRO
  229.                          _AEDuplicateDesc
  230.                          MOVE.W           #$0405,D0
  231.                          _Pack8                      ; A816
  232.                          ENDM
  233.  
  234. ;*********************************************************************
  235. ; The following calls apply to AEDescList.
  236. ;  Since AEDescList is a subtype of AEDesc, the calls in the previous
  237. ;  section can also be used for AEDescList. All list and array indices are 1-based.
  238. ;  If the data was greater than maximumSize in the routines below, then actualSize will
  239. ;  be greater than maximumSize, but only maximumSize bytes will actually be retrieved.
  240.                          MACRO
  241.                          _AECreateList
  242.                          MOVE.W           #$0706,D0
  243.                          _Pack8                      ; A816
  244.                          ENDM
  245.  
  246.                          MACRO
  247.                          _AECountItems
  248.                          MOVE.W           #$0407,D0
  249.                          _Pack8                      ; A816
  250.                          ENDM
  251.  
  252.                          MACRO
  253.                          _AEPutPtr
  254.                          MOVE.W           #$0A08,D0
  255.                          _Pack8                      ; A816
  256.                          ENDM
  257.  
  258.                          MACRO
  259.                          _AEPutDesc
  260.                          MOVE.W           #$0609,D0
  261.                          _Pack8                      ; A816
  262.                          ENDM
  263.  
  264.                          MACRO
  265.                          _AEGetNthPtr
  266.                          MOVE.W           #$100A,D0
  267.                          _Pack8                      ; A816
  268.                          ENDM
  269.  
  270.                          MACRO
  271.                          _AEGetNthDesc
  272.                          MOVE.W           #$0A0B,D0
  273.                          _Pack8                      ; A816
  274.                          ENDM
  275.  
  276.                          MACRO
  277.                          _AESizeOfNthItem
  278.                          MOVE.W           #$082A,D0
  279.                          _Pack8                      ; A816
  280.                          ENDM
  281.  
  282.                          MACRO
  283.                          _AEGetArray
  284.                          MOVE.W           #$0D0C,D0
  285.                          _Pack8                      ; A816
  286.                          ENDM
  287.  
  288.                          MACRO
  289.                          _AEPutArray
  290.                          MOVE.W           #$0B0D,D0
  291.                          _Pack8                      ; A816
  292.                          ENDM
  293.  
  294.                          MACRO
  295.                          _AEDeleteItem
  296.                          MOVE.W           #$040E,D0
  297.                          _Pack8                      ; A816
  298.                          ENDM
  299.  
  300. ;*********************************************************************
  301. ;The following calls apply to AERecord.
  302. ;  Since AERecord is a subtype of AEDescList, the calls in the previous
  303. ;  sections can also be used for AERecord
  304. ;  an AERecord can be created by using AECreateList with isRecord set to true 
  305.                          MACRO
  306.                          _AEPutKeyPtr
  307.                          MOVE.W           #$0A0F,D0
  308.                          _Pack8                      ; A816
  309.                          ENDM
  310.  
  311.                          MACRO
  312.                          _AEPutKeyDesc
  313.                          MOVE.W           #$0610,D0
  314.                          _Pack8                      ; A816
  315.                          ENDM
  316.  
  317.                          MACRO
  318.                          _AEGetKeyPtr
  319.                          MOVE.W           #$0E11,D0
  320.                          _Pack8                      ; A816
  321.                          ENDM
  322.  
  323.                          MACRO
  324.                          _AEGetKeyDesc
  325.                          MOVE.W           #$0812,D0
  326.                          _Pack8                      ; A816
  327.                          ENDM
  328.  
  329.                          MACRO
  330.                          _AESizeOfKeyDesc
  331.                          MOVE.W           #$0829,D0
  332.                          _Pack8                      ; A816
  333.                          ENDM
  334.  
  335.                          MACRO
  336.                          _AEDeleteKeyDesc
  337.                          MOVE.W           #$0413,D0
  338.                          _Pack8                      ; A816
  339.                          ENDM
  340.  
  341.  
  342. ;    *********************************************************************
  343. ;    The following calls are used to pack and unpack parameters from records of
  344. ;    type AppleEvent. Since AppleEvent is a subtype of AERecord, the calls in the previous
  345. ;    sections can also be used for variables of type AppleEvent. The next six calls
  346. ;    are in fact identical to the six calls for AERecord.
  347.                          MACRO
  348.                          _AEPutParamPtr
  349.                          MOVE.W           #$0A0F,D0
  350.                          _Pack8                      ; A816
  351.                          ENDM
  352.  
  353.                          MACRO
  354.                          _AEPutParamDesc
  355.                          MOVE.W           #$0610,D0
  356.                          _Pack8                      ; A816
  357.                          ENDM
  358.  
  359.                          MACRO
  360.                          _AEGetParamPtr
  361.                          MOVE.W           #$0E11,D0
  362.                          _Pack8                      ; A816
  363.                          ENDM
  364.  
  365.                          MACRO
  366.                          _AEGetParamDesc
  367.                          MOVE.W           #$0812,D0
  368.                          _Pack8                      ; A816
  369.                          ENDM
  370.  
  371.                          MACRO
  372.                          _AESizeOfParam
  373.                          MOVE.W           #$0829,D0
  374.                          _Pack8                      ; A816
  375.                          ENDM
  376.  
  377.                          MACRO
  378.                          _AEDeleteParam
  379.                          MOVE.W           #$0413,D0
  380.                          _Pack8                      ; A816
  381.                          ENDM
  382.  
  383. ;*********************************************************************
  384. ;The following calls also apply to type AppleEvent.  Message attributes are far more restricted, and
  385. ;can only be accessed through the following 5 calls. The various list and record routines cannot be used
  386. ;to access the attributes of an event. 
  387.                          MACRO
  388.                          _AEGetAttributePtr
  389.                          MOVE.W           #$0E15,D0
  390.                          _Pack8                      ; A816
  391.                          ENDM
  392.  
  393.                          MACRO
  394.                          _AEGetAttributeDesc
  395.                          MOVE.W           #$0826,D0
  396.                          _Pack8                      ; A816
  397.                          ENDM
  398.  
  399.                          MACRO
  400.                          _AESizeOfAttribute
  401.                          MOVE.W           #$0828,D0
  402.                          _Pack8                      ; A816
  403.                          ENDM
  404.  
  405.                          MACRO
  406.                          _AEPutAttributePtr
  407.                          MOVE.W           #$0A16,D0
  408.                          _Pack8                      ; A816
  409.                          ENDM
  410.  
  411.                          MACRO
  412.                          _AEPutAttributeDesc
  413.                          MOVE.W           #$0627,D0
  414.                          _Pack8                      ; A816
  415.                          ENDM
  416.  
  417. ;*********************************************************************
  418. ; The next four calls are basic routines used to create, send, and process AppleEvents. 
  419.                          MACRO
  420.                          _AECreateAppleEvent
  421.                          MOVE.W           #$0B14,D0
  422.                          _Pack8                      ; A816
  423.                          ENDM
  424.  
  425.                          MACRO
  426.                          _AESend
  427.                          MOVE.W           #$0D17,D0
  428.                          _Pack8                      ; A816
  429.                          ENDM
  430.  
  431.                          MACRO
  432.                          _AEProcessAppleEvent
  433.                          MOVE.W           #$021B,D0
  434.                          _Pack8                      ; A816
  435.                          ENDM
  436.  
  437. ;During event processing, an event handler may realize that it is likely
  438. ;to exceed the client's timeout limit. Passing the reply to this
  439. ;routine causes a wait event to be generated to ask the client for more time. 
  440.                          MACRO
  441.                          _AEResetTimer
  442.                          MOVE.W           #$0219,D0
  443.                          _Pack8                      ; A816
  444.                          ENDM
  445.  
  446. ;  *********************************************************************
  447. ;The following four calls are available for applications which need more sophisticated control
  448. ;over when and how events are processed. Applications which implement multi-session servers or 
  449. ;which implement their own internal event queueing will probably be the major clients of these
  450. ;routines.  
  451.  
  452. ; Can be called from within a handler to prevent the AEM from disposing of
  453. ;the AppleEvent when the handler returns. Can be used to asynchronously process the 
  454. ;event (as in MacApp).
  455.                          MACRO
  456.                          _AESuspendTheCurrentEvent
  457.                          MOVE.W           #$022B,D0
  458.                          _Pack8                      ; A816
  459.                          ENDM
  460.  
  461.  
  462. ;     Tells the AppleEvent manager that processing is either about to resume or has
  463. ;    been completed on a previously suspended event. The procPtr passed in as the
  464. ;    dispatcher parameter will be called to attempt to redispatch the event. Several
  465. ;    constants for the dispatcher parameter allow special behavior. They are:
  466. ;    - kAEUseStandardDispatch means redispatch as if the event was just received, using the
  467. ;        standard AppleEvent Dispatcher.
  468. ;    - kAENoDispatch means ignore the parameter.
  469. ;        Use this in the case where no redispatch is needed, and the event has been handled.
  470. ;    - non nil means call the routine which dispatcher points to.
  471.                          MACRO
  472.                          _AEResumeTheCurrentEvent
  473.                          MOVE.W           #$0818,D0
  474.                          _Pack8                      ; A816
  475.                          ENDM
  476.  
  477. ;Allows application to examine the currently executing event
  478.                          MACRO
  479.                          _AEGetTheCurrentEvent
  480.                          MOVE.W           #$021A,D0
  481.                          _Pack8                      ; A816
  482.                          ENDM
  483.  
  484. ;Set the current event to the parameter
  485.                          MACRO
  486.                          _AESetTheCurrentEvent
  487.                          MOVE.W           #$022C,D0
  488.                          _Pack8                      ; A816
  489.                          ENDM
  490.  
  491.  
  492. ;    *********************************************************************
  493. ;     The following three calls are used to allow applications to behave courteously 
  494. ;    when a user interaction such as a dialog box is needed. 
  495.                          MACRO
  496.                          _AEGetInteractionAllowed
  497.                          MOVE.W           #$021D,D0
  498.                          _Pack8                      ; A816
  499.                          ENDM
  500.  
  501.                          MACRO
  502.                          _AESetInteractionAllowed
  503.                          MOVE.W           #$011E,D0
  504.                          _Pack8                      ; A816
  505.                          ENDM
  506.  
  507.                          MACRO
  508.                          _AEInteractWithUser
  509.                          MOVE.W           #$061C,D0
  510.                          _Pack8                      ; A816
  511.                          ENDM
  512.  
  513. ; *********************************************************************
  514. ; These calls are used to set up and modify the event dispatch table  }
  515. ;{ Add an AppleEvent Handler 
  516.                          MACRO
  517.                          _AEInstallEventHandler
  518.                          MOVE.W           #$091F,D0
  519.                          _Pack8                      ; A816
  520.                          ENDM
  521.  
  522. ; Remove an AppleEvent Handler 
  523.                          MACRO
  524.                          _AERemoveEventHandler
  525.                          MOVE.W           #$0720,D0
  526.                          _Pack8                      ; A816
  527.                          ENDM
  528.  
  529. ; Get the corresponding AppleEvent Handler 
  530.                          MACRO
  531.                          _AEGetEventHandler
  532.                          MOVE.W           #$0921,D0
  533.                          _Pack8                      ; A816
  534.                          ENDM
  535.  
  536. ; *********************************************************************
  537. ; These calls are used to set up and modify the coercion dispatch table  
  538.                          MACRO
  539.                          _AEInstallCoercionHandler
  540.                          MOVE.W           #$0A22,D0
  541.                          _Pack8                      ; A816
  542.                          ENDM
  543.  
  544. ; Remove a Coercion Handler 
  545.                          MACRO
  546.                          _AERemoveCoercionHandler
  547.                          MOVE.W           #$0723,D0
  548.                          _Pack8                      ; A816
  549.                          ENDM
  550.  
  551. ; Get the corresponding Coercion Handler 
  552.                          MACRO
  553.                          _AEGetCoercionHandler
  554.                          MOVE.W           #$0B24,D0
  555.                          _Pack8                      ; A816
  556.                          ENDM
  557.  
  558.  
  559. ;      *********************************************************************
  560. ;    These calls are used to set up and modify special hooks into the AppleEvent Manager.
  561.  
  562. ;    Install the special handler named by the Keyword  
  563.                          MACRO
  564.                          _AEInstallSpecialHandler
  565.                          MOVE.W           #$0500,D0
  566.                          _Pack8                      ; A816
  567.                          ENDM
  568.  
  569. ; Remove the special handler named by the Keyword 
  570.                          MACRO
  571.                          _AERemoveSpecialHandler
  572.                          MOVE.W           #$0501,D0
  573.                          _Pack8                      ; A816
  574.                          ENDM
  575.  
  576. ; Get the special handler named by the Keyword 
  577.                          MACRO
  578.                          _AEGetSpecialHandler
  579.                          MOVE.W           #$052D,D0
  580.                          _Pack8                      ; A816
  581.                          ENDM
  582.  
  583.                          ENDIF    ;       ...already included